<?php
/**
 * CPortlet class file.
 *
 * @author Lucas Vasconcelos <contato@lucasvasconcelos.com>
 * @copyright Copyright(c) 2010 Lucas Vasconcelos
 * @license BSD License http://www.lucasvasconcelos.com/yap/license
 * @link http://www.lucasvasconcelos.com/yap/
 * @version $Id: CPortlet.php 3 2010-01-28 03:49:35Z contato@lucasvasconcelos.com $
 * @package yap.web.portlets
 */

/**
 * CPortlet class.
 *
 * @author Lucas Vasconcelos <contato@lucasvasconcelos.com>
 * @version 1.0 $Revision: 3 $
 * @package yap.web.portlets
 */
class CPortlet extends TTemplateControl
{
	/**
	 * CPortlet child classes can require a especial class to be your container.
	 * @throws TInvalidOperationException
	 */
	public function onInit($param)
	{
		parent::onInit($param);
		if(!$this->getPage() instanceof $this->RequiredParent)
			throw new TInvalidOperationException("{$this->Name} portlet requires a {$this->RequiredParent} as container.");
	}

	/**
	 * @return string the portlet class name.
	 */
	public function getName()
	{
		return get_class($this);
	}

	/**
	 * @return string required parent class name.
	 */
	public function getRequiredParent()
	{
		return 'CPage';
	}
}